cmake_minimum_required( VERSION 2.6 )
INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
SET(CMAKE_CXX_FLAGS_DEBUG 
    "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi")
SET(CMAKE_C_FLAGS_DEBUG 
    "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /MAP /MAPINFO:EXPORTS") 
add_definitions(-DHAVE_ROW_BASED_REPLICATION -DMYSQL_SERVER 
                -D_CONSOLE -DHAVE_DLOPEN -D__BH_ENTERPRISE__ -DEMBEDDED_LIBRARY)
if(WIN32)
	add_definitions("-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE")
endif(WIN32)

set( IB_ROOT "${CMAKE_SOURCE_DIR}/../../" )
set( BH_ROOT "${IB_ROOT}/src/storage/brighthouse/" )
set( VENDOR_ROOT "${IB_ROOT}/vendor/mysql-5.1.40-ent/" )
include_directories( "${BH_ROOT}/"
	"${VENDOR_ROOT}/include"
	"${IB_ROOT}/test"
	"${IB_ROOT}/tools/UnitTest++/src"
	"${VENDOR_ROOT}/sql"
	"${VENDOR_ROOT}/extra/yassl/include"
	"${VENDOR_ROOT}/zlib"
	"${VENDOR_ROOT}/regex"
  "${BH_ROOT}/{EDITION}"
	"{BOOST_DIR}" )

file( GLOB_RECURSE SRCS ${IB_ROOT}/test/*.cpp )
add_executable( UnitTest++ ${SRCS} )
SET_TARGET_PROPERTIES( UnitTest++ PROPERTIES COMPILE_FLAGS "-EHsc -D__BH_JUST_A_LIBRARY__" )
add_dependencies( UnitTest++ GenError mysqld udf_example)

TARGET_LINK_LIBRARIES( UnitTest++
											"${IB_ROOT}/build/UnitTest++/debug/UnitTest++.lib"
                      "${BH_ROOT}/win/compress/debug/bh-compress.lib"
                      "${BH_ROOT}/win/core/debug/bh-core.lib"
                      "${BH_ROOT}/win/common/debug/bh-common.lib"
                      "${BH_ROOT}/win/engine/debug/bh-engine.lib"
                      "${BH_ROOT}/win/handler/debug/bh-handler.lib"
                      "${BH_ROOT}/win/loader/debug/bh-loader-lib.lib"
                      "${BH_ROOT}/win/memmngr/debug/bh-memmngr.lib"
                      "${BH_ROOT}/win/system/debug/bh-system.lib"
                      "${BH_ROOT}/win/vc/debug/bh-vc.lib"
                      "${BH_ROOT}/win/domaininject/debug/bh-domaininject.lib"
											"${VENDOR_ROOT}/sql/Debug/sql.lib"
											"${VENDOR_ROOT}/extra/yassl/Debug/yassl.lib"
											"${VENDOR_ROOT}/extra/yassl/taocrypt/Debug/taocrypt.lib"
											"${VENDOR_ROOT}/dbug/Debug/dbug.lib"
											"${VENDOR_ROOT}/mysys/Debug/mysys.lib"
											"${VENDOR_ROOT}/regex/Debug/regex.lib"
											"${VENDOR_ROOT}/sql/Debug/udf_example.lib"
											"${VENDOR_ROOT}/storage/heap/Debug/heap.lib"
											"${VENDOR_ROOT}/storage/myisam/Debug/myisam.lib"
											"${VENDOR_ROOT}/storage/csv/Debug/csv.lib"
											"${VENDOR_ROOT}/storage/myisammrg/Debug/myisammrg.lib"
											"${VENDOR_ROOT}/zlib/Debug/zlib.lib"
											"${VENDOR_ROOT}/strings/Debug/strings.lib"
											"${VENDOR_ROOT}/vio/Debug/vio.lib"
                      optimized "{BOOST_DIR}/lib/libboost_program_options-{BOOST_VERSION}.lib"
                      optimized "{BOOST_DIR}/lib/libboost_thread-{BOOST_VERSION}.lib"
                      optimized "{BOOST_DIR}/lib/libboost_date_time-{BOOST_VERSION}.lib"
                      optimized "{BOOST_DIR}/lib/libboost_regex-{BOOST_VERSION}.lib"
                      optimized "{BOOST_DIR}/lib/libboost_filesystem-{BOOST_VERSION}.lib" {BOOST_EXTRA_OPTIMIZED_LIBS} {BOOST_EXTRA_DEBUG_LIBS}
                      debug "{BOOST_DIR}/lib/libboost_program_options-{BOOST_DBG_VERSION}.lib"
                      debug "{BOOST_DIR}/lib/libboost_thread-{BOOST_DBG_VERSION}.lib"
                      debug "{BOOST_DIR}/lib/libboost_date_time-{BOOST_DBG_VERSION}.lib"
                      debug "{BOOST_DIR}/lib/libboost_regex-{BOOST_DBG_VERSION}.lib"
                      debug "{BOOST_DIR}/lib/libboost_filesystem-{BOOST_DBG_VERSION}.lib"
											wsock32)

SET_TARGET_PROPERTIES(UnitTest++ PROPERTIES LINK_FLAGS "/INCREMENTAL:NO /FORCE:MULTIPLE")

# enable_testing()
# add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -V)

## add the test runner as a test
# add_test(NAME TestUnitTestPP COMMAND TestUnitTest++ ${CONFIG_PATH} ${CONFIG_TASKS_PATH} ${SOUND_LOG_PATH})
# add_dependencies(check TestUnitTestPP)

# vim: ft=cmake
